-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TP2000-1478: Missing measures check #1359
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some screen shots of views and forms in the PR cover note could be useful.
b59c4ee
to
73ee57a
Compare
workbaskets/views/ui.py
Outdated
return super().get_queryset() | ||
|
||
@atomic | ||
def run_missing_measures_check(self, pks): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhap self-document this function?
def run_missing_measures_check(self, pks): | |
def run_missing_measures_check(self, comm_code_pks: list[int]) -> None: |
class MissingMeasuresCheck(TimestampedMixin): | ||
"""Stores a timestamp for when check_workbasket_for_missing_measures was | ||
last run, FK to the workbasket and whether the check was successful.""" | ||
|
||
workbasket = models.OneToOneField( | ||
"workbaskets.WorkBasket", | ||
on_delete=models.CASCADE, | ||
null=True, | ||
related_name="missing_measures_check", | ||
) | ||
|
||
successful = fields.BooleanField(null=True) | ||
|
||
|
||
class MissingMeasureCommCode(models.Model): | ||
"""Links a GoodsNomenclature to a MissingMeasuresCheck when the commodity | ||
fails the check.""" | ||
|
||
commodity = models.ForeignKey( | ||
"commodities.GoodsNomenclature", | ||
on_delete=models.CASCADE, | ||
) | ||
missing_measures_check = models.ForeignKey( | ||
MissingMeasuresCheck, | ||
on_delete=models.CASCADE, | ||
related_name="model_checks", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to take a different approach to business rule checks.
Business rule checks have a matching TrackedModelCheck.successful=True
and new timestamp for each WorkBasket TrackedModel
when all business rules have passed. But if there's an incomplete set of TrackedModelCheck
s, or one or more with a successful
attribute set to False
, or timestamp older than TrackedModel.updated_at
, then business rules are considered to have failed.
Goods are unlikely to change in a workbasket. But measures may do, which would make a clean MissingMeasuresCheck
instance invalid. Is staleness and check completeness validation required or supported in this implementation?
Either way, a docstring would be useful, perhaps in MissingMeasuresCheck
, to say a little about the checking strategy because of the differing approaches.
TP2000-1478: Missing measures check
Why
What
MissingMeasuresCheck
andMissingMeasureCommCode
addedWorkBasket
model -missing_measures_check_task_id
. Functions the same asrule_check_task_id
Still to do
Checklist